package com.tastyshop.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.tastyshop.dao.UserReviewBoardMapper;
import com.tastyshop.domain.UserReviewBoard;

@Service
@Transactional

public class UserReviewBoardServiceImpl implements UserReviewBoardService{

	@Autowired
	private UserReviewBoardMapper mapper;

	@Override
	public List<UserReviewBoard> getUserReviewBoardList(String field,
			String keyword, int page, int rows) {
		Map<Object, Object> params = new HashMap<Object, Object>();
		params.put("field", field);
		if(!"".equals(keyword)){
			params.put("keyword", keyword);
		}else{
			params.put("keyword", "");
		}
		params.put("page", page);
		params.put("rows", rows);
		return mapper.getUserReviewBoardList(params);
	}

	@Override
	public void UserReviewInsert(UserReviewBoard UserReviewBoard) {
		mapper.userReviewInsert(UserReviewBoard);
		
	}

	@Override
	public HashMap<String, UserReviewBoard> getInfo(int idx) {
		HashMap<String, UserReviewBoard> map = new HashMap<>();
		map.put("userReviewBoard", mapper.getInfo(idx));
		map.put("prev", mapper.getPrev(idx));
		map.put("next", mapper.getNext(idx));
		return map;
	}

	@Override
	public void hitCount(Integer idx) {
		mapper.hitCount(idx);
		
	}

	@Override
	public void UserReviewModify(UserReviewBoard userReviewBoard) {
		mapper.userReviewModify(userReviewBoard);
		
	}

	@Override
	public void UserReviewDelete(Integer idx) {
		mapper.userReviewDelete(idx);
		
	}

	@Override
	public UserReviewBoard userReviewView(Integer idx) {
		return mapper.userReviewView(idx);
	}

	@Override
	public UserReviewBoard getUserReviewBoardByIdx(Integer idx) {
		return mapper.getUserReviewBoardByIdx(idx);
	}
	
	


}
